﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BaiduFanyi
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

       

        private void btn生成_Click(object sender, EventArgs e)
        {
            string propertyName= txt属性.Text;
           
            if (txt属性.Text.Contains("m_"))
            {
                propertyName = txt属性.Text.Substring(2, txt属性.Text.Length - 2);
            }

            string value = GetNotifyProperty(propertyName, txt解释.Text,txtType.Text);

            Clipboard.SetDataObject(value);//把内容复制到粘贴板
        }

        private string GetNotifyProperty(string property,string explan,string type)
        {
            StringBuilder sbValue = new StringBuilder();
            sbValue.AppendLine($"/// <summary>");
            sbValue.AppendLine($"///{explan}");
            sbValue.AppendLine($"/// </summary>");
            sbValue.AppendLine($"private {type} m_{property};");
            sbValue.AppendLine($"");
            sbValue.AppendLine($"/// <summary>");
            sbValue.AppendLine($"///{explan}");
            sbValue.AppendLine($"/// </summary>");
            sbValue.AppendLine($"public {type} {property}");
            sbValue.AppendLine($"{{");
            sbValue.AppendLine($" get {{ return m_{property}; }}");
            sbValue.AppendLine($"set");
            sbValue.AppendLine($"{{");
            sbValue.AppendLine($" m_{property} = value;");
            sbValue.AppendLine($"  this.RaisePropertyChanged(()=> {property});");
            sbValue.AppendLine($"}}");
            sbValue.AppendLine($"}}");
            return sbValue.ToString();
        }
    }
}
